
#include	"Object.h"

Object::Object(){
	objectSurface = NULL;
	visible = true;
	speedX = speedY = 0;
	x = y = 0;
}

bool Object::init(char* imageFile){

	if( (objectSurface = Surface::OnLoad(imageFile)) == NULL )
		return false;

	return true;
}

void Object::loop(){

	x += speedX * FPS::fpsControl.getSpeedFactor();
	y -= speedY * FPS::fpsControl.getSpeedFactor();
}

void Object::render(SDL_Surface* destSurface){

	if(visible)
		Surface::OnDraw(destSurface, objectSurface, x, y);
}

void Object::cleanup(){
	
	if(objectSurface)
		SDL_FreeSurface(objectSurface);
}

void Object::setVisible(bool v){
	visible = v;
}

void Object::setSpeedX(float s){
	this->speedX = s;
}

void Object::setSpeedY(float s){
	this->speedY = s;
}

void Object::setPos(float x, float y){
	setX(x);
	setY(y);
}

void Object::setX(float x){
	this->x = x;
}

void Object::setY(float y){
	this->y = y;
}
